function getEndTime(myYear){
    var myEndTime = new Date(''+myYear+'/06/07 00:00:00');/*创建对象，字符串相加，设置截至时间*/
    return myEndTime;
}

function countDown(){
    var mydate = new Date();
    var year = '2022';
    var EndTime = getEndTime(year);/*结束时间*/
    var NowTime = new Date();/*现在时间*/
    if( (EndTime.getTime() - NowTime.getTime() ) < 0){/*判断，如果现在时间超过结束时间，年加一*/
        year = mydate.getFullYear() + 1;
        EndTime = getEndTime(year);
    }
    var t = EndTime.getTime() - NowTime.getTime();/*间隔时间*/



    var d=Math.floor(t/1000/60/60/24);/*求出天数*/
    var h=Math.floor(t/1000/60/60%24);/*小时*/
    var m=Math.floor(t/1000/60%60);/*分钟*/
    var s=Math.floor(t/1000%60);/*秒*/

    document.getElementById('day').innerText = d;/*赋值倒数时间*/ 
    document.getElementById('hour').innerText = h;
    document.getElementById('minute').innerText = m;
    document.getElementById('second').innerText = s;
} 
setInterval(countDown,1000);